package com.woniuxy.commons.filter;

import com.woniuxy.commons.jwt.UserConst;
import com.woniuxy.commons.util.WebUtil;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.stereotype.Component;

/**
 * @auther 黄磊
 * @2022/7/14 18:50
 **/
@Component
public class TokenFilter  implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate template) {
        if(WebUtil.getRequest()==null){
            return;
        }
        String token = WebUtil.getRequest().getHeader("Authorization");
        if (token !=null && !token.trim().equals("")){
            template.header("Authorization",token);
        }
    }
}
